package tech.treec.smartlight.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import java.util.List;
import java.util.Map;

import tech.treec.smartlight.R;

/**
 * Created by Young on 2025/1/20.
 */
public class MyListAdapter extends BaseAdapter {

    private Context mContext;
    private List<String> mList;

    private int mViewId;

    public MyListAdapter(Context context, int viewId, List<String> list) {
        this.mContext = context;
        this.mList = list;
        this.mViewId = viewId;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(mViewId, null);

           viewHolder.nameTX = convertView.findViewById(R.id.tv);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        viewHolder.nameTX.setText(mList.get(position));

        return convertView;
    }

    class ViewHolder {
               private TextView nameTX;

    }

}